package com.fc.example;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import androidx.appcompat.app.AppCompatActivity;

import com.anythink.core.api.ATAdConst;
import com.anythink.core.api.ATNetworkConfig;
import com.anythink.core.api.ATSDK;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        // 加载广告
        this.findViewById(R.id.bt_1).setOnClickListener(it -> toActivity(InterstitialActivity.class));


        // 展示广告
        this.findViewById(R.id.bt_2).setOnClickListener(it -> {
            toActivity(FeedExpressActivity.class);
        });

        // 展示广告
        this.findViewById(R.id.bt_3).setOnClickListener(it -> {
            toActivity(SplashActivity.class);
        });

        // 加载广告
        this.findViewById(R.id.bt_4).setOnClickListener(v -> {
            initATNativeAd();
            loadAd();
        });

        // 加载广告
        this.findViewById(R.id.bt_5).setOnClickListener(v -> {
            toActivity(RewardVideoActivity.class);
        });

        //初始化SDK
        ATSDK.integrationChecking(getApplicationContext());//注意：不要在提交上架审核的包中带上此API，避免影响上架
        ATSDK.setNetworkLogDebug(true);//应用上线前须关闭
        ATSDK.setPersonalizedAdStatus(ATAdConst.PRIVACY.PERSIONALIZED_ALLOW_STATUS);
        ATNetworkConfig atNetworkConfig = new ATNetworkConfig.Builder().build();
        ATSDK.init(getApplicationContext(), "a659bba85986de", "ad7dfc1537901530affaba1724e163bf2", atNetworkConfig);
    }

    private void initATNativeAd() {
        ATNativeNew.getATNative(this);
    }

    private void loadAd() {
        ATNativeNew.request(this);
    }

    private void toActivity(Class<?> cls) {
        Intent intent = new Intent(this, cls);
        startActivity(intent);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
    }
}